package pub.cleangao.mybatis.quick;

import pub.cleangao.mybatis.execution.ReadExecution;
import pub.cleangao.mybatis.expression.Expressions;
import pub.cleangao.mybatis.expression.Tables;


/**
 * 查询操作
 */
public class Select implements Quick<Object> {

    private final ReadExecution execution;

    private Select(ReadExecution execution) {
        this.execution = execution;
    }

    public static Select from(String table) {
        return new Select(ReadExecution.startSelect(table));
    }

    public static Select from(Tables tables) {
        return new Select(ReadExecution.startSelect(tables));
    }

    public Select where(Expressions expression) {
        execution.setWhereExpressionList(expression.getWhereExpressionList());
        return this;
    }

    @Override
    public Object done() throws Exception {
        return execution.done();
    }


}
